//
//  ViewController.m
//  FDT
//
//  Created by boom on 2017/6/7.
//  Copyright © 2017年 boomLi. All rights reserved.
//

#import "ViewController.h"
#import "UITableView+FDTemplateLayoutCell.h"
#import "TableViewCell.h"
#import "Model.h"

@interface ViewController ()<UITableViewDelegate, UITableViewDataSource>{
    NSMutableArray * jsonArr;
    
}

@property (nonatomic, strong) UITableView * myTableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _myTableView = [[UITableView alloc] initWithFrame:self.view.frame];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    _myTableView.fd_debugLogEnabled = YES;
    [_myTableView registerNib:[UINib nibWithNibName:@"TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_myTableView];
    
    NSArray * data = @[@"sdlkaskldklsahdkjhsakjhdjkshdkjsahdjksahjkdbhsajkdbjksabdhkjsabhdjkashdjkashdjkashdjkahsjkdhasjkhdjkasbhdkjaskjhjkas", @"dkぁjlkjklhjklfkぁsjfヵfjlさkljfkぁjフィオジェfjkldldjさjfdかhfkjさhkfjskdじゃfjkhdsjkfhdさjkhfjksdhfjksdhfkjsdhfsjkhjfksd", @"范德雷克撒娇哭了饭就撒开了房间里是克己复礼看见圣诞快乐房间看了电视剧弗兰克时间到了咖啡可乐的实时监控寥寥可数的几款礼服简单快乐放假快乐的时间疯狂拉德斯基六块腹肌阿斯科利附近开了手机翻看了多少积分可怜的手机付款来得急索科洛夫觉得索科洛夫就打开了手机翻看了多少积分可怜的手机翻看了多少积分快乐的时间疯狂拉德斯基疯狂拉萨的借口   1", @"safakfklsjfkldsklfjkdlsjfjdslfjkdlsjfkldjsfdjfklsklfjsdlkfdsjfkljkljkljklfjdksafedfsklajjkkl", @"fdmbnkjeDfo;m,kloq;,mdfnsanfoennn,maefdmma,nfewlkkljkflsadfeno;nvcdsla;jeojndasf"];
    
    jsonArr = @[].mutableCopy;
    
    [data enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        Model * model = [Model new];
        model.title = obj;
        [jsonArr addObject:model];
    }];
    
    
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return jsonArr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
//    cell.fd_enforceFrameLayout = NO;
    cell.model = jsonArr[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [self.myTableView fd_heightForCellWithIdentifier:@"cell" cacheByIndexPath:indexPath configuration:^(TableViewCell *cell) {
//        cell.fd_enforceFrameLayout = NO;
        cell.model = jsonArr[indexPath.row];
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
